import random

class Character:
    def __init__(self, Str, dex, vit, ene, Gold, Name):
        self.strength = Str
        self.dexterity = dex
        self.vitality = vit
        self.energy = ene
        self.maxHealth = vit * 20
        self.health = self.maxHealth
        self.maxMana = ene * 10
        self.mana = self.maxMana
        self.defense = Str * 1.5
        self.magdef = ene * 1.5
        self.atkMeleeMin = Str * 4
        self.atkMeleeMax = Str * 6
        self.atkRangedMin = dex * 4
        self.atkRangedMax = dex * 6
        self.atkMagicMin = ene * 4
        self.atkMagicMax = ene * 6
        self.gold = Gold
        self.name = Name
        self.evasion = dex * 5
        self.accuracy = dex * 5
        self.criticalRate = ((dex + (Str/2))/2) * 5
        
    def getAttackPhrase(self, Type):
        if self.name is "Goblin":
            if Type == "physical":
                return "The "+str(self.name)+" looks around stupidly and decides to attack you."
            if Type == "magic":
                return "The "+str(self.name)+" looks around cleverly and decides to cast a spell."
        if self.name is "Dog":
            if Type == "physical":
                return "The "+str(self.name)+" charges and bites you in the arm."
            if Type == "magic":
                return "The "+str(self.name)+" jumps around looking cute, and casts a spell."
        if self.name is "Bunny":
            if Type == "physical":
                return "The "+str(self.name)+" jumps around looking cute, and jumps at you."
            if Type == "magic":
                return "The "+str(self.name)+" jumps around looking cute, and casts a spell."

    def getRawMeleeDamage(self):
        return random.randint(self.atkMeleeMin,self.atkMeleeMax)
    def getRawRangedDamage(self):
        return random.randint(self.atkRangedMin,self.atkRangedMax)
    def getRawMagicDamage(self):
        return random.randint(self.atkMagicMin,self.atkMagicMax)

    def receivePhyDamage(self, dmg):
        if dmg > self.defense:
            self.health -= dmg + self.defense
        if self.health < 0:
            self.health = 0
    def receiveMagDamage(self, dmg):
        if dmg > self.magdef:
            self.health -= dmg + self.magdef
        if self.health < 0:
            self.health = 0
            
    def stats(self): #Updating Values
        self.maxHealth = self.vitality * 20
        self.maxMana = self.energy * 10
        self.defense = self.strength * 1.5
        self.magdef = self.energy * 1.5
        self.atkMeleeMin = self.strength * 4
        self.atkMeleeMax = self.strength * 6
        self.atkRangedMin = self.dexterity * 4
        self.atkRangedMax = self.dexterity * 6
        self.atkMagicMin = self.energy * 4
        self.atkMagicMax = self.energy * 6
        self.evasion = self.dexterity * 5
        self.accuracy = self.dexterity * 5
        self.criticalRate = ((self.dexterity + (self.strength/2))/2) * 5
